let obj = {a: 1, fn: '123'};

Function.prototype.myCall = function (target, ...args) {
  const func = this;
  let fn = Symbol('fn');
  target[fn] = func;
  let result = target[fn](...args);
  delete target[fn];
  return result;
};


Function.prototype.myApply = function (target, arr) {
  if (!Array.isArray(arr)) {
    throw new TypeError('please parse value is typeof array!');
  }
  const func = this;
  let fn = Symbol('fn');
  target[fn] = func;
  let result = target[fn](arr);
  delete target[fn];
  return result;
};

function fnChange(...args) {
  console.log(this);
  return 12;
}

// let res = fnChange.myCall(obj, 10, 20, 30);
let res = fnChange.myApply(obj, [1, 2, 3]);


// let res = fnChange.call(obj, 12, 230); // v8内核 :
//
console.log(res);
